import { ref,reactive,computed } from 'vue'
import { defineStore } from 'pinia'
import { pageHeros } from "@/api/hero";

export const useHeroStore = defineStore('hero', () => {
    const heros = reactive([
        {
            "heroName" : "提莫",
            "heroImg": "/api/file/download/1822098531859021826"
        },
    ])

    const heroPage = reactive({
        pageNum:1,
        pageSize:12,
        total:0,
        datas: []
    })

    const pageDTO = reactive({
        pageNum:1,
        pageSize:12,
        name:""
    })
    const getHeroPage = async ()=>{
        const res = await pageHeros(pageDTO);
        const data = res.data.data;
        heroPage.pageNum = parseInt(data.pageNum);
        heroPage.pageSize = parseInt(data.pageSize);
        heroPage.total = parseInt(data.total);
        heroPage.datas = data.datas;
    }


    return { heroPage, getHeroPage , pageDTO}
})
